#include<iostream>
#include<string.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int ne[N];
char s[N];
LL f[N];
int n;
int main()
{
	while (scanf("%s", s + 1) != EOF) {
		n = strlen(s + 1);
		for (int i = 0; i <= n; i++) {
			f[i] = 0;
			ne[i] = 0;
		}
		LL ans = 0;
		//printf("%s",s+1);
		//cout<<n<<endl;
		for (int i = 2, j = 0; i <= n; i++) {
			while (j && s[i] != s[j + 1])j = ne[j];
			if (s[i] == s[j + 1])j++;
			ne[i] = j;
			//ans += ne[i];
		}
		for (int i = 2; i <= n; i++) {
			int x = ne[i];
			f[i] = f[x] + ne[i];
			ans += f[i];
		}
		cout << ans << endl;
	}
	return 0;
}